package pro.cherish.knowledgeumldesignpattern.designPattern.com.cherish.observer.jdk;

public class client {
    public static void main(String [] args) {
//        创建目标对象Obserable
        ConcreteSubject concreteSubject = new ConcreteSubject();
//       创建观察者
        ObserverA o1 = new ObserverA();
        ObserverA o2 = new ObserverA();
        ObserverA o3 = new ObserverA();
//      将三个观察者对象添加到目标对象那个subject的观察者容器中
        concreteSubject.addObserver(o1);
        concreteSubject.addObserver(o2);
        concreteSubject.addObserver(o3);
    //        改变目标对象的状态
        concreteSubject.set(2000);
        System.out.println("状态修改了");
        System.out.println(o1.getMyState());
        System.out.println(o2.getMyState());
        System.out.println(o3.getMyState());
        //        改变目标对象的状态
        concreteSubject.set(25000);
        System.out.println("状态修改了");
        System.out.println(o1.getMyState());
        System.out.println(o2.getMyState());
        System.out.println(o3.getMyState());
    }
}
